from fastapi import FastAPI, Request

from app.initialization.init_sqlalchemy import db_session

async def middleware_db(request: Request, call_next):
    # 在这里修改依赖项
    request.state.db = db_session() # 将 db 存储到 request.state
    response = await call_next(request)
    return response
